﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Chizx.Web.major
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Session["UserEntity"])
            {
                Response.Redirect("/e/Login.aspx");
            }
			if (!Page.IsPostBack)
			{
				int zm_id = -1;
				if (Request.Params["id0"] != null && Request.Params["id0"].Trim() != "")
				{
					zm_id=(Convert.ToInt32(Request.Params["id0"]));
				}
				int zd_id = -1;
				if (Request.Params["id1"] != null && Request.Params["id1"].Trim() != "")
				{
					zd_id=(Convert.ToInt32(Request.Params["id1"]));
				}
				#warning 代码生成提示：显示页面,请检查确认该语句是否正确
				ShowInfo(zm_id,zd_id);
			}
		}
			
	private void ShowInfo(int zm_id,int zd_id)
	{
		Chizx.BLL.MajorBll bll=new Chizx.BLL.MajorBll();
		Chizx.Model.MajorModel model=bll.GetModel(zm_id,zd_id);
		this.lblzm_id.Text=model.zm_id.ToString();
		this.lblzd_id.Text=model.zd_id.ToString();
		this.txtzm_name.Text=model.zm_name;
		this.txtzm_createdate.Text=model.zm_createdate.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtzm_name.Text.Trim().Length==0)
			{
				strErr+="zm_name不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtzm_createdate.Text))
			{
				strErr+="zm_createdate格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int zm_id=int.Parse(this.lblzm_id.Text);
			int zd_id=int.Parse(this.lblzd_id.Text);
			string zm_name=this.txtzm_name.Text;
			DateTime zm_createdate=DateTime.Parse(this.txtzm_createdate.Text);


			Chizx.Model.MajorModel model=new Chizx.Model.MajorModel();
			model.zm_id=zm_id;
			model.zd_id=zd_id;
			model.zm_name=zm_name;
			model.zm_createdate=zm_createdate;

            //写入系统日志
            if (Session["UserEntity"] == null)
            {
                Response.Redirect("/e/Login.aspx");
            }
            else
            {
                Chizx.BLL.MajorBll bll = new Chizx.BLL.MajorBll();
                bll.Update(model);
                Chizx.Model.UserModel sbmmodel = (Chizx.Model.UserModel)Session["UserEntity"];
                Chizx.BLL.SystemLogBll sbll = new Chizx.BLL.SystemLogBll();
                Chizx.Model.SystemLogModel slm = new Chizx.Model.SystemLogModel();
                slm.zu_id = sbmmodel.zu_id;
                slm.zl_dowhen = DateTime.Now;
                slm.zl_dowhat = "修改专业信息";
                slm.zl_dotype = "3";//0:Test,1:Auth,2:Read,3:Write,4:Del,5:Inpor
                slm.zl_dodesc = "操作成功";
                sbll.Add(slm);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");
            }

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
